package com.hodge.web.controller;

import com.hodge.core.enums.ResultCode;
import com.hodge.core.result.Result;
import org.springframework.boot.autoconfigure.web.servlet.error.AbstractErrorController;
import org.springframework.boot.web.servlet.error.ErrorAttributes;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by 张皓竣 on 2020/8/28
 */
@Controller
public class ErrorController extends AbstractErrorController {
    public ErrorController(ErrorAttributes errorAttributes) {
        super(errorAttributes);
    }

    @Override
    public String getErrorPath() {
        return "/error";
    }

    /**
     * 处理服务端 500 异常
     */
    @RequestMapping(value = "/error")
    @ResponseBody
    public Result error() {
        return ResultCode.SERVER_ERROR.toResult();
    }
}
